package material

import (
	"context"
	"device-admin/config/mysql"
	"device-admin/internal/dao"
	"device-admin/internal/define"
	"device-admin/internal/models"
	"strconv"
	"strings"
	"unicode/utf8"

	"192.168.1.75/go-pkg/errorx"
	"192.168.1.75/go-pkg/logx"
	"github.com/samber/lo"
)

type MaterialTheme struct{}

type ConfigsStruct struct {
	Condition int   `json:"condition"`
	Voice     []int `json:"voice"`
	Emoji     []int `json:"emoji"`
	Light     []int `json:"light"`
}

// 创建身份
func (MaterialTheme) ThemeSave(ctx context.Context, merchantID, userName, ID, name, soundSource string, permanent int, startTime, endTime int64, personalityPrompt string, configs []ConfigsStruct) (err error) {
	db := mysql.NewDB()
	if name == "" {
		return errorx.New("身份名称不能为空", -1)
	}
	if utf8.RuneCountInString(name) > 12 {
		return errorx.New("身份名称不能超过12个字符", -1)
	}
	if soundSource == "" {
		return errorx.New("音源不能为空", -1)
	}
	if permanent != 0 && permanent != 1 {
		return errorx.New("有效周期错误", -1)
	}
	if permanent == 0 && (startTime == 0 || endTime == 0) {
		return errorx.New("有效周期错误", -1)
	}
	if permanent == 1 {
		startTime = 0
		endTime = 0
	}
	if len(configs) == 0 {
		return errorx.New("身份配置不能为空", -1)
	}
	//关联素材列表
	MaterialList, _, _ := dao.Material{}.List(ctx, db, merchantID, "", nil, 1, 1, "", 0, 0)
	var MaterialMap = make(map[int]int)
	for _, v := range MaterialList {
		MaterialMap[int(v.MaterialID)] = v.Type
	}

	//触发条件
	var ConditionMap = make(map[int]string)
	for _, v := range define.MaterialCondition {
		ConditionMap[v.ID] = v.Name
	}
	var BatchThemeConfig []models.MaterialThemeConfig
	for _, config := range configs {
		var item models.MaterialThemeConfig
		item.MerchantID = merchantID
		// 触发条件
		if _, ok := ConditionMap[config.Condition]; !ok {
			return errorx.New("触发条件不存在", -1)
		}
		if len(config.Voice) == 0 {
			return errorx.New("播报语音不能为空", -1)
		}
		if config.Condition == 1 && len(config.Emoji) == 0 {
			return errorx.New("待机页表情展示不能为空", -1)
		}
		if config.Condition != 1 && len(config.Emoji) > 0 {
			return errorx.New("非待机页不允许设置表情", -1)
		}
		if config.Condition < 17 && len(config.Light) == 0 {
			return errorx.New("灯光效果不能为空", -1)
		}
		item.Condition = config.Condition
		// 语音
		voiceIDs := []string{}
		for _, voice := range config.Voice {
			if _, ok := MaterialMap[voice]; ok {
				if MaterialMap[voice] != 1 && MaterialMap[voice] != 2 { // 1文案语音 2音频语音
					err = errorx.New("关联语音不存在", -1)
					return
				}
			} else {
				err = errorx.New("关联语音不存在", -1)
				return
			}
			voiceIDs = append(voiceIDs, strconv.Itoa(voice))
		}
		item.Voice = strings.Join(voiceIDs, ",")
		// 表情
		emojiIDs := []string{}
		for _, emoji := range config.Emoji {
			if _, ok := MaterialMap[emoji]; ok {
				if MaterialMap[emoji] != 3 { // 3情绪表情
					err = errorx.New("关联表情不存在", -1)
					return
				}
			} else {
				err = errorx.New("关联表情不存在", -1)
				return
			}
			emojiIDs = append(emojiIDs, strconv.Itoa(emoji))
		}
		item.Emoji = strings.Join(emojiIDs, ",")
		// 灯光
		lightIDs := []string{}
		for _, light := range config.Light {
			if _, ok := MaterialMap[light]; ok {
				if MaterialMap[light] != 4 { // 4灯光
					err = errorx.New("关联灯光不存在", -1)
					return
				}
			} else {
				err = errorx.New("关联灯光不存在", -1)
				return
			}
			lightIDs = append(lightIDs, strconv.Itoa(light))
		}
		item.Light = strings.Join(lightIDs, ",")
		BatchThemeConfig = append(BatchThemeConfig, item)
	}

	if ID == "" { //新增
		//身份名称校验
		NameExistCount, _ := dao.MaterialTheme{}.SameNameExist(ctx, db, merchantID, name, "")
		if NameExistCount > 0 {
			return errorx.New("身份名称已被占用", -1)
		}
		//写入身份表
		ID, _ = dao.MaterialTheme{}.Create(ctx, db, merchantID, userName, name, soundSource, permanent, startTime, endTime, personalityPrompt)
	} else { //编辑
		// 身份信息校验
		_, ThemeCount, _ := dao.MaterialTheme{}.Detail(ctx, db, merchantID, ID, "")
		if ThemeCount == 0 {
			return errorx.New("身份信息不存在", -1)
		}
		// 身份名称校验
		NameExistCount, _ := dao.MaterialTheme{}.SameNameExist(ctx, db, merchantID, name, ID)
		if NameExistCount > 0 {
			return errorx.New("身份名称已被占用", -1)
		}
		// 编辑身份信息
		dao.MaterialTheme{}.Update(ctx, db, ID, name, soundSource, permanent, startTime, endTime, personalityPrompt)

		// 同步身份设备表
		db.Model(&models.MaterialThemeTerminals{}).
			Where("theme_id = ? and upgrade_type != 3", ID).
			Updates(map[string]interface{}{
				"upgrade_status": 0,
				"upgrade_type":   2, // 编辑
			})
		// 删除旧配置
		dao.MaterialThemeConfig{}.Delete(ctx, db, ID)
	}

	// 写入身份配置表
	for _, v := range BatchThemeConfig {
		dao.MaterialThemeConfig{}.Create(ctx, db, merchantID, ID, v.Condition, v.Voice, v.Emoji, v.Light)
	}
	return
}

// 绑定设备
func (MaterialTheme) BindDevice(ctx context.Context, MerchantID, themeID, BelongDevice string) (err error) {

	logx.Info(context.Background(), "BindDevice", logx.Any("MerchantID", MerchantID), logx.Any("themeID", themeID), logx.Any("BelongDevice", BelongDevice))
	db := mysql.NewDB()
	if BelongDevice == "" {
		err = errorx.New("设备信息必填", -1)
		return
	}
	if themeID == "" {
		err = errorx.New("身份信息必须", -1)
		return
	}
	//设备权限校验
	var DeviceList = []models.Device{}
	db.Model(&models.Device{}).
		Select("id, robot_id, merchant_id").
		Find(&DeviceList)
	var DeviceMap = make(map[string]string)
	for _, v := range DeviceList {
		DeviceMap[v.RobotID] = v.RobotID
	}

	logx.Info(context.Background(), "BindDevice", logx.Any("DeviceMap", len(DeviceMap)))
	//逗号分隔多个设备
	BindDeviceList := strings.Split(BelongDevice, ",")
	for _, v := range BindDeviceList {
		if _, ok := DeviceMap[v]; !ok {
			err = errorx.New("设备不存在", -1)
			return
		}
	}
	//判断设备是否已经绑定其他身份
	var ExistDeviceTheme []struct {
		ThemeID string `gorm:"column:theme_id"`
		RobotID string `gorm:"column:robot_id"`
	}
	db.Model(&models.MaterialThemeTerminals{}).
		Where("robot_id in (?)", BindDeviceList).
		Where("theme_id != ?", themeID).
		Where("upgrade_type != 3"). // 3 待删除
		Select("theme_id,robot_id").
		Find(&ExistDeviceTheme)

	logx.Info(context.Background(), "BindDevice", logx.Any("ExistDeviceTheme", len(ExistDeviceTheme)))
	if len(ExistDeviceTheme) > 0 {
		// 取消原来的身份绑定
		for _, v := range ExistDeviceTheme {
			dao.MaterialThemeTerminals{}.PreDelete(ctx, db, v.ThemeID, v.RobotID)
		}
	}
	//身份信息校验
	_, Count, _ := dao.MaterialTheme{}.Detail(ctx, db, MerchantID, themeID, "")
	if Count == 0 {
		logx.Info(context.Background(), "BindDevice", logx.Any("身份不存在", ""))
		err = errorx.New("身份不存在", -1)
		return
	}
	//获取身份对应的所有设备
	var ThemeDevice = []models.MaterialThemeTerminals{}
	db.Model(&models.MaterialThemeTerminals{}).
		Where("theme_id = ?", themeID).
		Find(&ThemeDevice)
	var ThemeDeviceMap = make(map[string]string) //robot_id + "_" + terminal_type
	var ThemeDeleteDeviceMap = make(map[string]string)

	logx.Info(context.Background(), "BindDevice", logx.Any("ThemeDevice", len(ThemeDevice)))
	for _, v := range ThemeDevice {
		ThemeDeviceMap[v.RobotID+"_"+v.TerminalType] = v.RobotID
		ThemeDeleteDeviceMap[v.RobotID] = v.RobotID
	}
	//新增或编辑身份绑定的设备
	for _, robotID := range BindDeviceList {
		if _, ok := ThemeDeviceMap[robotID+"_"+"97"]; !ok { //新增 97

			dao.MaterialThemeTerminals{}.Create(ctx, db, themeID, robotID, "97", 0, 1)
			logx.Info(context.Background(), "BindDevice", logx.Any("97 MaterialThemeTerminals Create robotID", robotID), logx.Any("themeID", themeID))
		} else { //编辑 97
			delete(ThemeDeleteDeviceMap, robotID)
			db.Model(&models.MaterialThemeTerminals{}).
				Where("theme_id = ?", themeID).
				Where("robot_id = ? and terminal_type = 97", robotID).
				Updates(map[string]interface{}{
					"upgrade_status": 0,
					"upgrade_type":   2, //编辑
				})

			logx.Info(context.Background(), "BindDevice", logx.Any("97 MaterialThemeTerminals Update robotID", robotID), logx.Any("themeID", themeID))
		}

		if _, ok := ThemeDeviceMap[robotID+"_"+"98"]; !ok { //新增 98
			dao.MaterialThemeTerminals{}.Create(ctx, db, themeID, robotID, "98", 0, 1)
			logx.Info(context.Background(), "BindDevice", logx.Any("98 MaterialThemeTerminals Create robotID", robotID), logx.Any("themeID", themeID))
		} else { //编辑 98
			delete(ThemeDeleteDeviceMap, robotID)
			db.Model(&models.MaterialThemeTerminals{}).
				Where("theme_id = ?", themeID).
				Where("robot_id = ? and terminal_type = 98", robotID).
				Updates(map[string]interface{}{
					"upgrade_status": 0,
					"upgrade_type":   2, //编辑
				})
			logx.Info(context.Background(), "BindDevice", logx.Any("98 MaterialThemeTerminals Update robotID", robotID), logx.Any("themeID", themeID))
		}
	}
	//删除取消绑定的设备
	deleteDeviceList := lo.MapToSlice(ThemeDeleteDeviceMap, func(k string, v string) string { return v })
	dao.MaterialThemeTerminals{}.PreDelete(ctx, db, themeID, strings.Join(deleteDeviceList, ","))
	logx.Info(context.Background(), "BindDevice", logx.Any("PreDelete", ""))
	return
}

type ThemeListStruct struct {
	models.MaterialTheme
	BelongDeviceList []string `gorm:"-" json:"belong_device_list"`
}

// 身份列表
func (MaterialTheme) ThemeList(ctx context.Context, MerchantID, Name string, Page, Limit int) (data []ThemeListStruct, count int64, err error) {
	db := mysql.NewDB()
	list, count, _ := dao.MaterialTheme{}.List(ctx, db, MerchantID, "", Name, Page, Limit)
	data = []ThemeListStruct{}
	if count == 0 {
		return
	}
	var themeIDList []string
	for _, v := range list {
		data = append(data, ThemeListStruct{MaterialTheme: *v})
		themeIDList = append(themeIDList, v.ID)
	}
	var ThemeBelongDevices = []models.MaterialThemeTerminals{}
	db.Model(&models.MaterialThemeTerminals{}).
		Where("theme_id in (?)", themeIDList).
		Where("upgrade_type != 3"). // 待删除的不显示
		Group("theme_id, robot_id").
		Select("theme_id, robot_id").
		Find(&ThemeBelongDevices)
	var ThemeDeviceMap = make(map[string][]string)
	for _, v := range ThemeBelongDevices {
		ThemeDeviceMap[v.ThemeID] = append(ThemeDeviceMap[v.ThemeID], v.RobotID)
	}
	for k, v := range data {
		data[k].BelongDeviceList = []string{}
		if _, ok := ThemeDeviceMap[v.ID]; ok {
			data[k].BelongDeviceList = ThemeDeviceMap[v.ID]
		}
	}
	return
}

type ThemeDetailStruct struct {
	ID                string                    `json:"id" gorm:"column:id"`
	Name              string                    `json:"name" gorm:"column:name"`
	SoundSource       string                    `json:"sound_source" gorm:"column:sound_source"`
	PersonalityPrompt string                    `json:"personality_prompt" gorm:"column:personality_prompt"`
	Permanent         int                       `json:"permanent" gorm:"column:permanent"`
	StartTime         int64                     `json:"start_time" gorm:"column:start_time"`
	EndTime           int64                     `json:"end_time" gorm:"column:end_time"`
	CreatedAt         int64                     `json:"created_at" gorm:"column:created_at"`
	UpdatedAt         int64                     `json:"updated_at" gorm:"column:updated_at"`
	Configs           []ConditionMaterialConfig `json:"configs" gorm:"-"`
}

type ConditionMaterialConfig struct {
	Condition     int                   `json:"condition"`
	ConditionName string                `json:"condition_name"`
	Voice         []VoiceMaterialConfig `json:"voice"`
	Emoji         []EmojiMaterialConfig `json:"emoji"`
	Light         []LightMaterialConfig `json:"light"`
}
type VoiceMaterialConfig struct {
	MaterialID int    `json:"material_id"`
	Type       int    `json:"type"`
	Name       string `json:"name"`
	Content    string `json:"content"`
	FilePath   string `json:"file_path"`
}
type EmojiMaterialConfig struct {
	MaterialID int    `json:"material_id"`
	Type       int    `json:"type"`
	Name       string `json:"name"`
	Content    string `json:"content"`
	FilePath   string `json:"file_path"`
}

type LightMaterialConfig struct {
	MaterialID int    `json:"material_id"`
	Type       int    `json:"type"`
	Name       string `json:"name"`
	Content    string `json:"content"`
}

// 身份详情
func (MaterialTheme) ThemeDetail(ctx context.Context, MerchantID, ID string) (data ThemeDetailStruct, err error) {
	db := mysql.NewDB()
	data = ThemeDetailStruct{}
	ThemeInfo, Count, _ := dao.MaterialTheme{}.Detail(ctx, db, MerchantID, ID, "")
	if Count == 0 {
		return
	}
	var ConditionMap = make(map[int]string)
	for _, v := range define.MaterialCondition {
		ConditionMap[v.ID] = v.Name
	}
	data.ID = ThemeInfo.ID
	data.Name = ThemeInfo.Name
	data.SoundSource = ThemeInfo.SoundSource
	data.Permanent = ThemeInfo.Permanent
	data.PersonalityPrompt = ThemeInfo.PersonalityPrompt
	data.StartTime = ThemeInfo.StartTime
	data.EndTime = ThemeInfo.EndTime
	data.CreatedAt = ThemeInfo.CreatedAt
	data.UpdatedAt = ThemeInfo.UpdatedAt
	data.Configs = []ConditionMaterialConfig{}
	// 关联素材列表
	MaterialList, _, _ := dao.Material{}.List(ctx, db, MerchantID, "", nil, 1, 1, "", 0, 0)
	var MaterialMap = make(map[int]struct {
		ID       int    `json:"id"`
		Type     int    `json:"type"`
		Name     string `json:"name"`
		Content  string `json:"content"`
		FilePath string `json:"file_path"`
	})
	for _, v := range MaterialList {
		MaterialMap[int(v.MaterialID)] = struct {
			ID       int    `json:"id"`
			Type     int    `json:"type"`
			Name     string `json:"name"`
			Content  string `json:"content"`
			FilePath string `json:"file_path"`
		}{
			ID:       int(v.MaterialID),
			Type:     v.Type,
			Name:     v.Name,
			Content:  v.Content,
			FilePath: v.FilePath,
		}
	}

	// 配置列表
	ConfigList, _, _ := dao.MaterialThemeConfig{}.List(ctx, db, MerchantID, ThemeInfo.ID, 0, 0)
	for _, condition := range ConfigList {
		// 触发条件
		var ConditionConfig = ConditionMaterialConfig{}
		ConditionConfig.Condition = condition.Condition
		if _, ok := ConditionMap[ConditionConfig.Condition]; ok {
			ConditionConfig.ConditionName = ConditionMap[ConditionConfig.Condition]
		}

		// 语音
		for _, voice := range strings.Split(condition.Voice, ",") {
			voiceMaterialID, _ := strconv.Atoi(voice)
			if _, ok := MaterialMap[voiceMaterialID]; ok {
				var voiceItem = VoiceMaterialConfig{}
				voiceItem.MaterialID = voiceMaterialID
				voiceItem.Type = MaterialMap[voiceMaterialID].Type
				voiceItem.Name = MaterialMap[voiceMaterialID].Name
				voiceItem.Content = MaterialMap[voiceMaterialID].Content
				voiceItem.FilePath = MaterialMap[voiceMaterialID].FilePath
				ConditionConfig.Voice = append(ConditionConfig.Voice, voiceItem)
			}
		}

		// 表情
		for _, emoji := range strings.Split(condition.Emoji, ",") {
			emojiMaterialID, _ := strconv.Atoi(emoji)
			if _, ok := MaterialMap[emojiMaterialID]; ok {
				var emojiItem = EmojiMaterialConfig{}
				emojiItem.MaterialID = emojiMaterialID
				emojiItem.Type = MaterialMap[emojiMaterialID].Type
				emojiItem.Name = MaterialMap[emojiMaterialID].Name
				emojiItem.Content = MaterialMap[emojiMaterialID].Content
				emojiItem.FilePath = MaterialMap[emojiMaterialID].FilePath
				ConditionConfig.Emoji = append(ConditionConfig.Emoji, emojiItem)
			}
		}

		// 灯光
		for _, light := range strings.Split(condition.Light, ",") {
			lightMaterialID, _ := strconv.Atoi(light)
			if _, ok := MaterialMap[lightMaterialID]; ok {
				var lightItem = LightMaterialConfig{}
				lightItem.MaterialID = lightMaterialID
				lightItem.Type = MaterialMap[lightMaterialID].Type
				lightItem.Name = MaterialMap[lightMaterialID].Name
				lightItem.Content = MaterialMap[lightMaterialID].Content
				ConditionConfig.Light = append(ConditionConfig.Light, lightItem)
			}
		}
		data.Configs = append(data.Configs, ConditionConfig)
	}
	return
}

// 身份删除
func (MaterialTheme) ThemeDelete(ctx context.Context, MerchantID, ID string) (err error) {
	db := mysql.NewDB()
	_, count, _ := dao.MaterialTheme{}.Detail(ctx, db, MerchantID, ID, "")
	if count == 0 {
		return errorx.New("身份不存在", -1)
	}

	// 删除身份配置
	dao.MaterialTheme{}.Delete(ctx, db, ID)
	// 删除配置详情
	dao.MaterialThemeConfig{}.Delete(ctx, db, ID)
	// 删除绑定设备
	dao.MaterialThemeTerminals{}.PreDelete(ctx, db, ID, "")
	return nil
}

// 获取默认身份配置【模板默认选中项】
func (MaterialTheme) DefaultThemeConfig(ctx context.Context) (res []ConditionMaterialConfig, err error) {
	//触发条件
	var ConditionMap = make(map[int]string)
	for _, v := range define.MaterialCondition {
		ConditionMap[v.ID] = v.Name
	}
	//关联语音
	var VoiceMap = make(map[int]define.MaterialStruct)
	for _, v := range define.MaterialVoice {
		VoiceMap[int(v.ID)] = v
	}
	//关联表情
	var EmojiMap = make(map[int]define.MaterialStruct)
	for _, v := range define.MaterialEmoji {
		EmojiMap[int(v.ID)] = v
	}
	//关联灯光
	var LightMap = make(map[int]define.LightStruct)
	for _, v := range define.MaterialLight {
		LightMap[int(v.ID)] = v
	}
	var DefaultThemeConfigList = []ConditionMaterialConfig{
		{
			Condition:     1, // 待机时(待机页)
			ConditionName: ConditionMap[1],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10100,
					Content:    VoiceMap[10100].Content,
				},
				{
					MaterialID: 10101,
					Content:    VoiceMap[10101].Content,
				},
				{
					MaterialID: 10102,
					Content:    VoiceMap[10102].Content,
				},
				{
					MaterialID: 10105,
					Content:    VoiceMap[10105].Content,
				},
				// {
				// 	MaterialID: 10106,
				// 	Content:    VoiceMap[10106].Content,
				// },
				{
					MaterialID: 10107,
					Content:    VoiceMap[10107].Content,
				},
				{
					MaterialID: 10111,
					Content:    VoiceMap[10111].Content,
				},
				{
					MaterialID: 10112,
					Content:    VoiceMap[10112].Content,
				},
				{
					MaterialID: 10113,
					Content:    VoiceMap[10113].Content,
				},
				{
					MaterialID: 10114,
					Content:    VoiceMap[10114].Content,
				},
				{
					MaterialID: 10115,
					Content:    VoiceMap[10115].Content,
				},
				{
					MaterialID: 10120,
					Content:    VoiceMap[10120].Content,
				},
				{
					MaterialID: 10122,
					Content:    VoiceMap[10122].Content,
				},
				{
					MaterialID: 10123,
					Content:    VoiceMap[10123].Content,
				},
				{
					MaterialID: 10124,
					Content:    VoiceMap[10124].Content,
				},
				{
					MaterialID: 10126,
					Content:    VoiceMap[10126].Content,
				},
			},
			Emoji: []EmojiMaterialConfig{
				{
					MaterialID: 40001,
					Name:       EmojiMap[40001].Name,
				},
				{
					MaterialID: 40002,
					Name:       EmojiMap[40002].Name,
				},
				{
					MaterialID: 40005,
					Name:       EmojiMap[40005].Name,
				},
				{
					MaterialID: 40008,
					Name:       EmojiMap[40008].Name,
				},
				{
					MaterialID: 40009,
					Name:       EmojiMap[40009].Name,
				},
				{
					MaterialID: 40010,
					Name:       EmojiMap[40010].Name,
				},
				{
					MaterialID: 40011,
					Name:       EmojiMap[40011].Name,
				},
				{
					MaterialID: 40012,
					Name:       EmojiMap[40012].Name,
				},
				{
					MaterialID: 40013,
					Name:       EmojiMap[40013].Name,
				},
				{
					MaterialID: 40014,
					Name:       EmojiMap[40014].Name,
				},
				{
					MaterialID: 40015,
					Name:       EmojiMap[40015].Name,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50016,
					Name:       LightMap[50016].Name,
				},
				{
					MaterialID: 50013,
					Name:       LightMap[50013].Name,
				},
				{
					MaterialID: 50012,
					Name:       LightMap[50012].Name,
				},
				{
					MaterialID: 50014,
					Name:       LightMap[50014].Name,
				},
				{
					MaterialID: 50011,
					Name:       LightMap[50011].Name,
				},
				{
					MaterialID: 50032,
					Name:       LightMap[50032].Name,
				},
				{
					MaterialID: 50028,
					Name:       LightMap[50028].Name,
				},
				{
					MaterialID: 50030,
					Name:       LightMap[50030].Name,
				},
				{
					MaterialID: 50027,
					Name:       LightMap[50027].Name,
				},
				{
					MaterialID: 50015,
					Name:       LightMap[50015].Name,
				},
				{
					MaterialID: 50031,
					Name:       LightMap[50031].Name,
				},
				{
					MaterialID: 50029,
					Name:       LightMap[50029].Name,
				},
			},
		},
		{
			Condition:     2, // 首页
			ConditionName: ConditionMap[2],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10118,
					Content:    VoiceMap[10118].Content,
				},
				{
					MaterialID: 10127,
					Content:    VoiceMap[10127].Content,
				},
				{
					MaterialID: 10133,
					Content:    VoiceMap[10133].Content,
				},
				{
					MaterialID: 10108,
					Content:    VoiceMap[10108].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50024,
					Name:       LightMap[50024].Name,
				},
				{
					MaterialID: 50021,
					Name:       LightMap[50021].Name,
				},
				{
					MaterialID: 50023,
					Name:       LightMap[50023].Name,
				},
			},
		},
		{
			Condition:     3, // 进入全部商品
			ConditionName: ConditionMap[3],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10043,
					Content:    VoiceMap[10043].Content,
				},
				{
					MaterialID: 10119,
					Content:    VoiceMap[10119].Content,
				},
				{
					MaterialID: 10134,
					Content:    VoiceMap[10134].Content,
				},
				{
					MaterialID: 10142,
					Content:    VoiceMap[10142].Content,
				},
				{
					MaterialID: 10143,
					Content:    VoiceMap[10143].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50024,
					Name:       LightMap[50024].Name,
				},
				{
					MaterialID: 50021,
					Name:       LightMap[50021].Name,
				},
				{
					MaterialID: 50023,
					Name:       LightMap[50023].Name,
				},
			},
		},
		{
			Condition:     4, // 返回全部商品
			ConditionName: ConditionMap[4],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10121,
					Content:    VoiceMap[10121].Content,
				},
				{
					MaterialID: 10137,
					Content:    VoiceMap[10137].Content,
				},
				{
					MaterialID: 10144,
					Content:    VoiceMap[10144].Content,
				},
				{
					MaterialID: 10145,
					Content:    VoiceMap[10145].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50020,
					Name:       LightMap[50020].Name,
				},
				{
					MaterialID: 50022,
					Name:       LightMap[50022].Name,
				},
				{
					MaterialID: 50019,
					Name:       LightMap[50019].Name,
				},
			},
		},
		{
			Condition:     5, // 返回首页
			ConditionName: ConditionMap[5],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10121,
					Content:    VoiceMap[10121].Content,
				},
				{
					MaterialID: 10131,
					Content:    VoiceMap[10131].Content,
				},
				{
					MaterialID: 10132,
					Content:    VoiceMap[10132].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50020,
					Name:       LightMap[50020].Name,
				},
				{
					MaterialID: 50022,
					Name:       LightMap[50022].Name,
				},
				{
					MaterialID: 50019,
					Name:       LightMap[50019].Name,
				},
			},
		},
		{
			Condition:     6, // 行驶中
			ConditionName: ConditionMap[6],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10100,
					Content:    VoiceMap[10100].Content,
				},
				{
					MaterialID: 10101,
					Content:    VoiceMap[10101].Content,
				},
				{
					MaterialID: 10102,
					Content:    VoiceMap[10102].Content,
				},
				{
					MaterialID: 10105,
					Content:    VoiceMap[10105].Content,
				},
				// {
				// 	MaterialID: 10106,
				// 	Content:    VoiceMap[10106].Content,
				// },
				{
					MaterialID: 10107,
					Content:    VoiceMap[10107].Content,
				},
				{
					MaterialID: 10111,
					Content:    VoiceMap[10111].Content,
				},
				{
					MaterialID: 10112,
					Content:    VoiceMap[10112].Content,
				},
				{
					MaterialID: 10113,
					Content:    VoiceMap[10113].Content,
				},
				{
					MaterialID: 10114,
					Content:    VoiceMap[10114].Content,
				},
				{
					MaterialID: 10115,
					Content:    VoiceMap[10115].Content,
				},
				{
					MaterialID: 10120,
					Content:    VoiceMap[10120].Content,
				},
				{
					MaterialID: 10122,
					Content:    VoiceMap[10122].Content,
				},
				{
					MaterialID: 10123,
					Content:    VoiceMap[10123].Content,
				},
				{
					MaterialID: 10124,
					Content:    VoiceMap[10124].Content,
				},
				{
					MaterialID: 10126,
					Content:    VoiceMap[10126].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50016,
					Name:       LightMap[50016].Name,
				},
				{
					MaterialID: 50013,
					Name:       LightMap[50013].Name,
				},
				{
					MaterialID: 50012,
					Name:       LightMap[50012].Name,
				},
				{
					MaterialID: 50014,
					Name:       LightMap[50014].Name,
				},
				{
					MaterialID: 50011,
					Name:       LightMap[50011].Name,
				},
				{
					MaterialID: 50032,
					Name:       LightMap[50032].Name,
				},
				{
					MaterialID: 50028,
					Name:       LightMap[50028].Name,
				},
				{
					MaterialID: 50030,
					Name:       LightMap[50030].Name,
				},
				{
					MaterialID: 50027,
					Name:       LightMap[50027].Name,
				},
				{
					MaterialID: 50015,
					Name:       LightMap[50015].Name,
				},
				{
					MaterialID: 50031,
					Name:       LightMap[50031].Name,
				},
				{
					MaterialID: 50029,
					Name:       LightMap[50029].Name,
				},
			},
		},
		{
			Condition:     7, // 进入支付页面
			ConditionName: ConditionMap[7],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10109,
					Content:    VoiceMap[10109].Content,
				},
				{
					MaterialID: 10110,
					Content:    VoiceMap[10110].Content,
				},
				{
					MaterialID: 10117,
					Content:    VoiceMap[10117].Content,
				},
				{
					MaterialID: 10125,
					Content:    VoiceMap[10125].Content,
				},
				{
					MaterialID: 10136,
					Content:    VoiceMap[10136].Content,
				},
				{
					MaterialID: 10146,
					Content:    VoiceMap[10146].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50019,
					Name:       LightMap[50019].Name,
				},
				{
					MaterialID: 50020,
					Name:       LightMap[50020].Name,
				},
				{
					MaterialID: 50022,
					Name:       LightMap[50022].Name,
				},
			},
		},
		{
			Condition:     8, // 进入出货步骤(支付成功)
			ConditionName: ConditionMap[8],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10138,
					Content:    VoiceMap[10138].Content,
				},
				{
					MaterialID: 10147,
					Content:    VoiceMap[10147].Content,
				},
				{
					MaterialID: 10148,
					Content:    VoiceMap[10148].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50033,
					Name:       LightMap[50033].Name,
				},
			},
		},
		{
			Condition:     9, // 停售
			ConditionName: ConditionMap[9],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10116,
					Content:    VoiceMap[10116].Content,
				},
				{
					MaterialID: 10128,
					Content:    VoiceMap[10128].Content,
				},
				{
					MaterialID: 10129,
					Content:    VoiceMap[10129].Content,
				},
				{
					MaterialID: 10130,
					Content:    VoiceMap[10130].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50007,
					Name:       LightMap[50007].Name,
				},
			},
		},
		{
			Condition:     10, // 支付失败
			ConditionName: ConditionMap[10],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10149,
					Content:    VoiceMap[10149].Content,
				},
				{
					MaterialID: 10150,
					Content:    VoiceMap[10150].Content,
				},
				{
					MaterialID: 10151,
					Content:    VoiceMap[10151].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50013,
					Name:       LightMap[50013].Name,
				},
			},
		},
		{
			Condition:     11, // 出货失败
			ConditionName: ConditionMap[11],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10139,
					Content:    VoiceMap[10139].Content,
				},
				{
					MaterialID: 10140,
					Content:    VoiceMap[10140].Content,
				},
				{
					MaterialID: 10141,
					Content:    VoiceMap[10141].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50016,
					Name:       LightMap[50016].Name,
				},
			},
		},
		{
			Condition:     12, // 进入人脸支付
			ConditionName: ConditionMap[12],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10152,
					Content:    VoiceMap[10152].Content,
				},
				{
					MaterialID: 10153,
					Content:    VoiceMap[10153].Content,
				},
				{
					MaterialID: 10154,
					Content:    VoiceMap[10154].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50019,
					Name:       LightMap[50019].Name,
				},
				{
					MaterialID: 50022,
					Name:       LightMap[50022].Name,
				},
				{
					MaterialID: 50020,
					Name:       LightMap[50020].Name,
				},
			},
		},
		{
			Condition:     13, // 进入商场导航
			ConditionName: ConditionMap[13],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10155,
					Content:    VoiceMap[10155].Content,
				},
				{
					MaterialID: 10156,
					Content:    VoiceMap[10156].Content,
				},
				{
					MaterialID: 10157,
					Content:    VoiceMap[10157].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50003,
					Name:       LightMap[50003].Name,
				},
				{
					MaterialID: 50006,
					Name:       LightMap[50006].Name,
				},
				{
					MaterialID: 50004,
					Name:       LightMap[50004].Name,
				},
			},
		},
		{
			Condition:     14, // 防碰撞触发>600s
			ConditionName: ConditionMap[14],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10165,
					Content:    VoiceMap[10165].Content,
				},
				{
					MaterialID: 10166,
					Content:    VoiceMap[10166].Content,
				},
				{
					MaterialID: 10167,
					Content:    VoiceMap[10167].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50010,
					Name:       LightMap[50010].Name,
				},
			},
		},
		{
			Condition:     15, // 里程触发>600s
			ConditionName: ConditionMap[15],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10168,
					Content:    VoiceMap[10168].Content,
				},
				{
					MaterialID: 10169,
					Content:    VoiceMap[10169].Content,
				},
				{
					MaterialID: 10170,
					Content:    VoiceMap[10170].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50010,
					Name:       LightMap[50010].Name,
				},
			},
		},
		{
			Condition:     16, // 出货成功
			ConditionName: ConditionMap[16],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 10158,
					Content:    VoiceMap[10158].Content,
				},
				{
					MaterialID: 10159,
					Content:    VoiceMap[10159].Content,
				},
				{
					MaterialID: 10160,
					Content:    VoiceMap[10160].Content,
				},
				{
					MaterialID: 10161,
					Content:    VoiceMap[10161].Content,
				},
			},
			Light: []LightMaterialConfig{
				{
					MaterialID: 50033,
					Name:       LightMap[50033].Name,
				},
			},
		},
		{
			Condition:     17, // 男性1人
			ConditionName: ConditionMap[17],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 6,
					Content:    VoiceMap[6].Content,
				},
				{
					MaterialID: 7,
					Content:    VoiceMap[7].Content,
				},
				{
					MaterialID: 10171,
					Content:    VoiceMap[10171].Content,
				},
			},
		},
		{
			Condition:     18, // 男性2人
			ConditionName: ConditionMap[18],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 12,
					Content:    VoiceMap[12].Content,
				},
				{
					MaterialID: 15,
					Content:    VoiceMap[15].Content,
				},
				{
					MaterialID: 16,
					Content:    VoiceMap[16].Content,
				},
				{
					MaterialID: 10172,
					Content:    VoiceMap[10172].Content,
				},
				{
					MaterialID: 10173,
					Content:    VoiceMap[10173].Content,
				},
				{
					MaterialID: 10178,
					Content:    VoiceMap[10178].Content,
				},
			},
		},
		{
			Condition:     19, // 女性1人
			ConditionName: ConditionMap[19],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 9,
					Content:    VoiceMap[9].Content,
				},
				{
					MaterialID: 10174,
					Content:    VoiceMap[10174].Content,
				},
				{
					MaterialID: 10175,
					Content:    VoiceMap[10175].Content,
				},
				{
					MaterialID: 10176,
					Content:    VoiceMap[10176].Content,
				},
			},
		},
		{
			Condition:     20, // 女性2人
			ConditionName: ConditionMap[20],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 12,
					Content:    VoiceMap[12].Content,
				},
				{
					MaterialID: 13,
					Content:    VoiceMap[13].Content,
				},
				{
					MaterialID: 14,
					Content:    VoiceMap[14].Content,
				},
				{
					MaterialID: 10177,
					Content:    VoiceMap[10177].Content,
				},
			},
		},
		{
			Condition:     21, // 男性1女性1
			ConditionName: ConditionMap[21],
			Voice: []VoiceMaterialConfig{
				{
					MaterialID: 11,
					Content:    VoiceMap[11].Content,
				},
				{
					MaterialID: 12,
					Content:    VoiceMap[12].Content,
				},
			},
		},
	}
	return DefaultThemeConfigList, nil
}
